package com.yzx.lifeassistants.adapter;

import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yzx.lifeassistants.R;
import com.yzx.lifeassistants.bean.RunningInfo;

/**
 * @Description: 我的约跑列表的适配器
 * @author: yzx
 * @time: 2015-9-15 下午1:54:14
 */
public class MyRunningAdapter extends BaseAdapter {
	private List<RunningInfo> dataList;
	private RunningInfo data;
	private LayoutInflater inflater;
	private ViewHolder holder;

	public MyRunningAdapter(Context context, List<RunningInfo> dataList) {
		this.dataList = dataList;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return dataList.size();
	}

	@Override
	public Object getItem(int position) {
		return dataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("HandlerLeak")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_my_running_listview,
					parent, false);
			holder = new ViewHolder();
			holder.describeTV = (TextView) convertView
					.findViewById(R.id.item_running_describe_tv);
			holder.timeTV = (TextView) convertView
					.findViewById(R.id.item_running_time_tv);
			holder.placeTV = (TextView) convertView
					.findViewById(R.id.item_running_place_tv);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		data = dataList.get(position);
		holder.describeTV.setText(data.getDescribe());
		holder.timeTV.setText(data.getTime());
		holder.placeTV.setText(data.getPlace());
		return convertView;
	}

	static class ViewHolder {
		TextView describeTV;// 描述
		TextView timeTV;// 时间
		TextView placeTV;// 地点
	}

}
